﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LuceneBasedStorage;
using NewsMine.Storage;

namespace NewsDiscoveryEngine
{
    [Serializable]
    public abstract class BaseJob
    {
        public string ID { get; set; }
        public string Name { get; set; }
        public int Timeout { get; set; }
        public int BufferDelayTime { get; set; }

        //public BaseJob NextJob { get; set; }
        //public Dictionary<string,BaseJob> OutputJobsInfo { get; set; } //Queue name, Job
        //public List<string> OutputStores { get; set; }

        //instead of have above properties, we need decide this flow in the Workflow.
        //lets attach the work flow, which will hold the logic of what todo on completion of each job.
        public BaseJobWorkFlow WorkFlow { get; set; }

        public delegate void OutputProducedDelegate(BaseJob job, object outputObject);
        public event OutputProducedDelegate OutputProduced;

        public BaseJob()
        {
        }

        public void ProcessOutput(object outputData)
        {
            if (OutputProduced != null)
                OutputProduced(this, outputData);
        }

        public abstract bool ExecuteJob();
    }
}
